

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>目录分片的配置 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="多活 MDS 守护进程的配置" href="../multimds/" />
    <link rel="prev" title="LazyIO" href="../lazyio/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">目录分片的配置</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/dirfrags.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id6">CephFS 内幕</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../mds-states/"> MDS 的各种状态</a></li>
<li class="toctree-l3"><a class="reference internal" href="../posix/"> POSIX 兼容性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-journaling/"> MDS 日志记录</a></li>
<li class="toctree-l3"><a class="reference internal" href="../file-layouts/"> 文件布局</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mdcache/"> 分布式元数据缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../dynamic-metadata-management/"> CephFS 内的动态元数据管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-io-path/"> CephFS IO 路径</a></li>
<li class="toctree-l3"><a class="reference internal" href="../charmap/"> 大小写敏感和规范化</a></li>
<li class="toctree-l3"><a class="reference internal" href="../lazyio/"> LazyIO</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 目录分片的配置</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id2">拆分和合并</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">尺寸阈值</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">活跃度阈值</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../multimds/"> 多活 MDS 的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snapshots/"> 快照</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="id1">
<h1>目录分片的配置<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h1>
<p>在 CephFS 中，目录变得非常大或非常繁忙时会被<em>分片</em>。
也就是把元数据拆分开，分成多个对象置于元数据存储池内，
以便由多个 MDS 守护进程共同处理。</p>
<p>在常规操作中，目录碎片对用户和管理员不可见，
并且这里提到的所有配置选项都应该维持其默认值。</p>
<p>目录分片功能使得 CephFS 能处理条目数量非常巨大的单个目录，
但是应用程序程序员仍然应该保守地创建巨型目录，
因为 CephFS 客户端罗列此目录时仍然耗费不少资源，
因为必须一次性加载所有分片。</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>根目录不能被分片。</p>
</div>
<p>所有目录最初创建时都是单个分片。
这个分片可以被 <em>分割</em> 、以便把目录分割成更多分片，
而且这些分片还可以 <em>合并</em> 、以减少目录内的分片数量。</p>
<section id="id2">
<h2>拆分和合并<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>当一个 MDS 确定了一个目录分片要分割，它不会立即进行分割。
因为分割动作会中断元数据 IO ，短暂的延迟是为了在开始分割前、
让客户端 IO 完成，会有短暂的爆发。
这个延时可以用 <code class="docutils literal notranslate"><span class="pre">mds_bal_fragment_interval</span></code> 配置，默认是 5 秒。</p>
<p>分割完成后，这个目录分片被分成了 2 的幂次个新分片。
新分片的数量是 2 的 <code class="docutils literal notranslate"><span class="pre">mds_bal_split_bits</span></code> 次方个，也就是，
假设 <code class="docutils literal notranslate"><span class="pre">mds_bal_split_bits</span></code> 是 2 ，那么将创建 4 个分片。
默认值是 3 ，也就是分割时会创建 8 个新分片。</p>
<p>初始化一个分割或合并操作的条件在下面几段描述。</p>
</section>
<section id="id3">
<h2>尺寸阈值<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>一个目录碎片的尺寸超过 <code class="docutils literal notranslate"><span class="pre">mds_bal_split_size</span></code>
（默认 10000 ）时就达到分割的条件了。通常，
此分割会被延迟 <code class="docutils literal notranslate"><span class="pre">mds_bal_fragment_interval</span></code> 长的时间，
但如果这个碎片尺寸超过分割尺寸的
<code class="docutils literal notranslate"><span class="pre">mds_bal_fragment_fast_factor</span></code> 倍数，分割就会立马开始
（先拦截着所有客户端在此目录上的元数据 IO ）。</p>
<p><code class="docutils literal notranslate"><span class="pre">mds_bal_fragment_size_max</span></code> 是目录分片尺寸的硬性限制。
如果达到了，客户端们如果想在这个分片里新建文件就会收到 ENOSPC 错误。在配置无误的系统上，
一般目录永远不会达到这个限值，因为它们早就被分割了。
默认情况下，此值设置成 10 倍于分割尺寸，
也就是 dirfrag 尺寸限值是 100000 。
增大这个限值会导致元数据存储池中的目录分片对象尺寸过于大，
这样 OSD 可能就没法处理了。</p>
<p>一个目录分片的尺寸小于 <code class="docutils literal notranslate"><span class="pre">mds_bal_merge_size</span></code> 时就可以被合并了。
前面说过的“快速分割”没有对等的合并操作：
快速分割的存在是为了避免创建尺寸过大的目录分片，
合并时没有需要避免的类似问题。
默认的合并尺寸是 50 。</p>
</section>
<section id="id4">
<h2>活跃度阈值<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>除了基于尺寸分割分片，
MDS 还能在目录分片的活跃度超过阈值时分割它。</p>
<p>MDS 为各个目录分片的读和写操作维护着独立的、
随时间衰减的负载计数器。衰减计数器有一个基于
<code class="docutils literal notranslate"><span class="pre">mds_decay_halflife</span></code> 配置选项的指数式衰减。</p>
<p>写入时，写计数器会递增、
并与 <code class="docutils literal notranslate"><span class="pre">mds_bal_split_wr</span></code> 比较、
如果阈值达到了还会触发一次分割。
写操作包括元数据 IO ，像重命名、解除连接和创建。</p>
<p><code class="docutils literal notranslate"><span class="pre">mds_bal_split_rd</span></code> 阈值是基于读操作负载计数器
（它跟踪 readdir 操作）应用的。</p>
<p><code class="docutils literal notranslate"><span class="pre">mds_bal_split_rd</span></code> 和 <code class="docutils literal notranslate"><span class="pre">mds_bal_split_wr</span></code> 配置表示热度阈值。
在 MDS 内，它们是用“读写温度”（ read/write temperatures ）来衡量的，
而它又与各自的读写操作密切相关。
默认情况下，读取阈值是 25000 个操作、
而写入阈值是 10000 个操作，
即读取是写入的 2.5 倍才会触发一次分割。</p>
<p>分片因达到活跃度阈值被分割后，
它们只有在达到尺寸阈值（ <code class="docutils literal notranslate"><span class="pre">mds_bal_merge_size</span></code> ）才会被合并，
所以，活跃度的一个爆发就会导致一个目录永远处于碎片状态，
除非删除一些条目。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../lazyio/" class="btn btn-neutral float-left" title="LazyIO" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../multimds/" class="btn btn-neutral float-right" title="多活 MDS 守护进程的配置" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>